package com.jeesite.modules.dp.service.patternstatics;

import com.jeesite.modules.dp.dao.patrernstatics.MarketStrongStockDao;
import com.jeesite.modules.dp.entity.patrernstatics.MarketStrongStockEntity;
import com.jeesite.modules.stock.service.StockLogoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MarketStrongStockService {

    @Autowired
    private MarketStrongStockDao marketStrongStockDao;

    @Autowired
    private StockLogoService stockLogoService;

    public List<MarketStrongStockEntity> getLatestDataList() {
        List<MarketStrongStockEntity> list = marketStrongStockDao.getLatestDataList();
        if (list != null && !list.isEmpty()) {
            list.forEach(item ->
                    item.setLogo(stockLogoService.getLogoUrl(
                            item.getStockCode(),
                            item.getLogo(),
                    item.getExchange())));
        }

        return list;
    }
}
